package ooday01;
/** 学生类 */
public class Student {
    //成员变量
    String name;
    int age;
    String className;
    String stuId;
    //给成员变量赋初始值
    Student(){
    }
    Student(String name,int age){
        this.name=name;
        this.age=age;
    }
    Student(String name,int age,String className,String stuId){
        this.name =name;
        this.age = age;
        this.className = className;
        this.stuId = stuId;
    }
    //this:指代当前对象,那个对象调用方法它指的就是哪个对象
    //this 只能用在方法中,方法中访问成员变量之前默认有个this.
    //方法
    void study(){
        System.out.println(this.name+"在学习...");
    }
    void sayHi(){
        System.out.println("大家好,我叫"+this.name+"今年"+this.age+"岁了," +
                "所在班级为"+this.className+"学号为"+this.stuId);
    }
    void play(String anothername){
        System.out.println(this.name+"正在和"+anothername+"一起玩...");
    }
}